
package com.apes.fn.crm.ReturnVisit.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.apes.fn.crm.customer.FnCustomer;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.ApesConst;
import com.apes.framework.util.DateUtil;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import com.apes.scm.masterdata.party.model.AccessProvider;
import com.apes.scm.masterdata.party.model.PartyRole;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.Date;

/**
 * 回访客户扩展表
 *
 * @author bbyford
 * @create 2020-2-5
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicUpdate
@DynamicInsert
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = VisitCustomerExpand.CONST_TABLE_NAME)
public class VisitCustomerExpand extends Model {
    public static final String CONST_TABLE_NAME = "fn_visit_customer_expand";

    @Id
    @Comment("编码")
    @Column(name = "id", nullable = false, length = 32)
    @ApesGenerator(code = "fn_visit_customer_expand", name = "回访客户扩展表")
    private String id;

    @Comment("接入商")
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "access_provider_id", referencedColumnName = "id", nullable = false)
    private AccessProvider accessProvider;

    @Column(name = "mobile", length = 32, nullable = false)
    @Comment("客户手机号")
    private String mobile;

    @Comment("不回访标记")
    @Column(name = "not_visit_sign", columnDefinition = ApesConst.FIELD_BOOLEAN_FALSE)
    private boolean notVisitSign = false;

    @Comment("回访时间段")
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "visit_period", referencedColumnName = "id")
    private Enumeration visitPeriod;

    @Comment("上次回访日期")
    @JSONField(format = DateUtil.SHOW_DATETIME_FORMAT)
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "prev_visit_date")
    private Date prevVisitDate;
}


